{include file="public/head"}
{include file="public/left"}

<!-- content -->
<div class="main_02_r">

    <!--内容区域-->
    <div class="site_01">
        <span>当前位置：</span><a href="#">城事社</a><i>></i><a href="#">广告管理</a><i>></i><a href="#">展位列表</a>
    </div>

    <div class="nrq_01">
        <div class="gg_01">
            <span class=""><a href="{:url('advertising/index')}">广告列表</a></span><span class="on">展位列表</span>
        </div>
        <div class="gg_02">
            <div class="gg_03">

                <div class="hbgl_01">
                    <div class="fr">
                        <span>在展位置：<i>{$sum}</i></span><b></b><span>待展位置：<i>{$remain}</i></span><b></b><span>展位总数：<i>{$sum_space}</i></span>
                    </div>
                </div>

                <div class="xxfl_01">
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <th>序号</th>
                            <th>位置选择</th>
                            <th>编号</th>
                            <th>剩余</th>
                            <th>月费用</th>
                            <th>季费用</th>
                            <th>半年费用</th>
                            <th>年费用</th>
                            <th>显隐</th>
                            <th>操作</th>
                        </tr>
                        {volist name="arr" id="vo"}
                        <tr>
                            <td>{$vo.id}</td>
                            <td>{$vo.space_name}</td>
                            <td>{$vo.serial_number}</td>
                            <td><i class="i1">{$vo.count}</i>/{$vo.total_space}</td>
                            <td>{$vo.month_cost}</td>
                            <td>{$vo.season_cost}</td>
                            <td>{$vo.half_year_cost}</td>
                            <td>{$vo.year_cost}</td>
                            <td class="td7 flxx_click">
                                <em value="{$vo.id}" class="{if condition='$vo.show_flag == 0'}on{/if}"><b></b></em>
                            </td>
                            <td>
                                <a href="javascript:ajax_edit('{$vo.id}')" class="a_cz zwlbbj_click">编辑</a>
                            </td>
                        </tr>
                        {/volist}
                    </table>
                </div>
                <script type="text/javascript">
                    var layer = layui.layer,form = layui.form;
                    $(".flxx_click").each(function () {
                        $(this).find("em").click(function () {
                            var id = $(this).attr('value');
                            if ($(this).attr("class") != "on") {
                                $(this).addClass("on");
                                $.ajax({
                                    url:"{:url('advertising/ajax_show_flag')}",
                                    type: "POST",//方法类型
                                    // dataType: "json",//预期服务器返回的数据类型
                                    data: {"id":id,"show_flag":0},
                                    success: function (data) {
                                        if (data.code === 1) {

                                            layer.msg("<span style='margin-left: 18px;'>"+data.msg+"</span>",{icon: 1,time:1000},function(){
                                                //window.location.href=data.url;

                                            });
                                        }else{
                                            layer.msg("<span style='margin-left: 18px;'>"+data.msg+"</span>",{icon: 2,time:1000},function(){
                                                if(data.url){
                                                    window.location.href=data.url;
                                                }else{
                                                    location.reload();
                                                }
                                            });
                                        }
                                    },
                                    error : function() {
                                        layer.msg("<span style='margin-left: 18px;'>请求错误,请联系管理员</span>",{icon: 0,time:1000},function(){
                                            location.reload();
                                        });
                                    }
                                });
                            }
                            else {
                                $(this).removeClass("on");
                                $.ajax({
                                    url:"{:url('advertising/ajax_show_flag')}",
                                    type: "POST",//方法类型
                                    // dataType: "json",//预期服务器返回的数据类型
                                    data: {"id":id,"show_flag":1},
                                    success: function (data) {
                                        if (data.code === 1) {

                                            layer.msg("<span style='margin-left: 18px;'>"+data.msg+"</span>",{icon: 1,time:1000},function(){
                                                //window.location.href=data.url;

                                            });
                                        }else{
                                            layer.msg("<span style='margin-left: 18px;'>"+data.msg+"</span>",{icon: 2,time:1000},function(){
                                                if(data.url){
                                                    window.location.href=data.url;
                                                }else{
                                                    location.reload();
                                                }
                                            });
                                        }
                                    },
                                    error : function() {
                                        layer.msg("<span style='margin-left: 18px;'>请求错误,请联系管理员</span>",{icon: 0,time:1000},function(){
                                            location.reload();
                                        });
                                    }
                                });
                            }
                        });
                    });
                </script>

                <div class="gg_03_b">
                    <div class="fl">
                        <span>共 <i>{$arr->total()}</i> 条</span><span>每页 <i>{$arr->listRows()}</i> 条</span>
                    </div>
                    <div class="fr">
                        {$arr->render()}
                    </div>
                </div>

            </div>
        </div>

    </div>

</div>
</div>


<!--展位列表-编辑弹窗-->
<div class="zwlbbj_fr">
    <div class="ggtcxq_bg"></div>
    <div class="ggtcxq_c">
        <div class="ggtcxq_cfr">
            <div class="ggtcxqc_t">
                <span>编辑</span><a href="javascript:void(0);" class="close"></a>
            </div>
            <div class="jgsp_02">
                <form class="ajax_form_add" action="{:url('advertising/ajax_edit_submit')}">
                <p>
                    <span>位置选择</span>
                    <input type="text" name="space_name" class="jgsp_02_txt" placeholder="请输入广告位置名称" />
                    <input type="hidden" name="id" class="jgsp_02_txt" placeholder="请输入广告位置名称" />
                </p>
                <p>
                    <span>编号</span>
                    <input type="text" name="serial_number" class="jgsp_02_txt" placeholder="请输入编号" />
                </p>
                <p>
                    <span>月费用</span>
                    <input type="text" name="month_cost" class="jgsp_02_txt" placeholder="请输入月费用" />
                </p>
                <p>
                    <span>季费用</span>
                    <input type="text" name="season_cost" class="jgsp_02_txt" placeholder="请输入季费用" />
                </p>
                <p>
                    <span>半年费用</span>
                    <input type="text" name="half_year_cost" class="jgsp_02_txt" placeholder="请输入半年费用" />
                </p>
                <p>
                    <span>年费用</span>
                    <input type="text" name="year_cost" class="jgsp_02_txt" placeholder="请输入年费用" />
                </p>
                <p>
                    <span>&nbsp;</span>
                    <input type="button" class="jgsp_02_btn ajax_submit_add" value="确定" />
                </p>
                </form>
            </div>

        </div>
    </div>
</div>
<script type="text/javascript">
    $(".zwlbbj_click").each(function () {
        $(this).click(function () {
            $(".zwlbbj_fr").show();
            $(".zwlbbj_fr .ggtcxq_c").css({ "margin-top": "-" + $(".zwlbbj_fr .ggtcxq_c").height() / 2 + "px" });
        });
    });
    $(".zwlbbj_fr .close").click(function () {
        $(".zwlbbj_fr").hide();
    });
    $(".zwlbbj_fr .ggtcxq_bg").click(function () {
        $(".zwlbbj_fr").hide();
    });
</script>

<script type="text/javascript">
    $(function () {
        var layer = layui.layer,form = layui.form;
        //发布公告
        $(".ajax_submit_add").click(function(){
            var url = $('.ajax_form_add').attr("action")?$('.ajax_form_add').attr("action"):"{:url()}";
            var data = $('.ajax_form_add').serialize();
            ajax_psot(url,data);
        });

        function ajax_psot(url,data){
            $.ajax({
                url:url,
                type: "POST",//方法类型
                // dataType: "json",//预期服务器返回的数据类型
                data: data,
                success: function (data) {
                    if (data.code === 1) {
                        layer.msg("<span style='margin-left: 18px;'>"+data.msg+"</span>",{icon: 1,time:1000},function(){
                            window.location.href=data.url;
                        });
                    }else{
                        layer.msg("<span style='margin-left: 18px;'>"+data.msg+"</span>",{icon: 2,time:1000},function(){
                            /*if(data.url){
                                window.location.href=data.url;
                            }else{
                                location.reload();
                            }*/
                        });
                    }
                },
                error : function() {
                    layer.msg("<span style='margin-left: 18px;'>请求错误,请联系管理员</span>",{icon: 0,time:1000},function(){
                        //location.reload();
                    });
                }
            });
        }
    })

    function ajax_edit(id) {
        $.ajax({
            url:"{:url('advertising/ajax_find')}",
            type: "POST",//方法类型
            // dataType: "json",//预期服务器返回的数据类型
            data: {"id":id},
            success: function (data) {
                if (data.code === 1) {
                    $("[name='space_name']").val(data.data.space_name);
                    $("[name='serial_number']").val(data.data.serial_number);
                    $("[name='month_cost']").val(data.data.month_cost);
                    $("[name='season_cost']").val(data.data.season_cost);
                    $("[name='half_year_cost']").val(data.data.half_year_cost);
                    $("[name='year_cost']").val(data.data.year_cost);
                    $("[name='id']").val(data.data.id);
                }else{
                    layer.msg("<span style='margin-left: 18px;'>"+data.msg+"</span>",{icon: 2,time:1000},function(){
                        if(data.url){
                            window.location.href=data.url;
                        }else{
                            location.reload();
                        }
                    });
                }
            },
            error : function() {
                layer.msg("<span style='margin-left: 18px;'>请求错误,请联系管理员</span>",{icon: 0,time:1000},function(){
                    location.reload();
                });
            }
        });
    }
</script>
<!-- content -->

{include file="public/foot"}